<?php
    include 'connectdb.php';
    $q1 = "select email from customer where email like '".$_POST['email']."'";
    $result1 = mysqli_query($link, $q1);
    mysqli_num_rows($result1);
    if (mysqli_num_rows($result1) != 0){
        echo '<script langquage="javascript">alert("มี email นี้ในระบบแล้วค่ะ");</script>';
        echo '<script langquage="javascript">window.location="register.php";</script>';
    }
    
    $q2 = "insert into customer (customer_id,customer_fname,customer_lname,phone_number,email,password)
            values ('','$_POST[f_name]','$_POST[l_name]','$_POST[phone]','$_POST[email]','$_POST[passwd]')";
    mysqli_query($link, $q2);
    mysqli_close($link);
    echo '<script langquage="javascript">alert("สมัครสมาชิกเรียบร้อยแล้วค่ะ");</script>';
    echo '<script langquage="javascript">window.location="index.php";</script>';
?>
